import { ApiPropertyOptional } from '@nestjs/swagger';
import {
  Column,
  Comment,
  DataType,
  Model,
  PrimaryKey,
  Table,
} from 'sequelize-typescript';
import { DataTypes } from 'sequelize';
import * as moment from 'moment';

@Table({
  tableName: 'rp_sys_code',
  timestamps: false,
})
export class SysCodeEntity extends Model<SysCodeEntity> {
  @ApiPropertyOptional({ description: 'id' })
  @Comment('id')
  @PrimaryKey
  @Column({
    type: DataTypes.BIGINT,
    primaryKey: true,
    allowNull: false,
    field: 'dqy_sys_code_xh',
  })
  dqySysCodeXh: number;

  @Comment('父级主键id')
  @Column({
    type: DataType.BIGINT,
    field: 'up_xh_id',
  })
  upXhId: number;

  @Comment('编码')
  @Column({
    type: DataTypes.CHAR,
    field: 'mb_dm',
  })
  mbDm: string;
  @Comment('编码名称')
  @Column({
    type: DataTypes.CHAR,
    field: 'mb_mc',
  })
  mbMc: string;
  @Comment('编码ID')
  @Column({
    type: DataTypes.CHAR,
    field: 'mz_dm',
  })
  mzDm: string;
  @Comment('编码值')
  @Column({
    type: DataTypes.CHAR,
    field: 'mz_mc',
  })
  mzMc: string;
  @Comment('内部排序')
  @Column({
    type: DataTypes.INTEGER,
    field: 'px',
  })
  px: number;
  @Comment('创建时间')
  @Column({
    type: DataTypes.DATE,
    field: 'lrrp',
    get() {
      const date = this.getDataValue('createDate');
      return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : '';
    },
  })
  lrrq: Date;
  @Comment('创建人')
  @Column({
    type: DataTypes.CHAR,
    field: 'lrr_dm',
  })
  lrrDm: string;
  @Comment('创建人姓名')
  @Column({
    type: DataTypes.CHAR,
    field: 'lrr_mc',
  })
  lrrMc: string;
  @Comment('更新时间')
  @Column({
    type: DataTypes.DATE,
    field: 'xgrp',
    get() {
      const date = this.getDataValue('createDate');
      return date ? moment(date).format('YYYY-MM-DD HH:mm:ss') : '';
    },
  })
  xgrq: Date;
  @Comment('更新人')
  @Column({
    type: DataTypes.CHAR,
    field: 'xgr_dm',
  })
  xgrDm: string;
  @Comment('更新人姓名')
  @Column({
    type: DataTypes.CHAR,
    field: 'xgr_mc',
  })
  xgrMc: string;
}
